package DataStructure.map;

import java.util.Map;
import java.util.Set;
import java.util.TreeMap;

public class TreeMaptest {
    public static void main(String[] args) {
        //实例化TreeMap容器
        Map<User,String> map = new TreeMap<>();

        //实例化User
        User user1 = new User("张三", 18);
        User user2 = new User("jing", 19);
        User user3 = new User("xst", 20);

        map.put(user1,user1.getName());
        map.put(user2,user1.getName());
        map.put(user3,user1.getName());

        //获取treemap容器中的key
        Set<User> users = map.keySet();
        for(User user:users){
            System.out.println(user+"-------"+map.get(user));
        }
    }
}
